

package com.jfinal.aceadmin.model;

import com.jfinal.ext.plugin.tablebind.TableBind;

import com.jfinal.plugin.activerecord.Db;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <a href="EmailAttachment.java.html"><b><i>View Source</i></b></a>
 *
 * @author Jason
 *
 */
@TableBind(tableName = "EmailAttachment", pkName = "baseId")
public class EmailAttachment extends BaseModel<EmailAttachment> {
	private static final long serialVersionUID = 1L;
	public static EmailAttachment dao = new EmailAttachment();

	public long getBaseId() {
		return this.get("baseId");
	}

	public void setBaseId(long baseId) {
		this.set("baseId", baseId);
	}

	public long getEmailId() {
		return this.get("emailId");
	}

	public void setEmailId(long emailId) {
		this.set("emailId", emailId);
	}

	public String getFileName() {
		return this.get("fileName");
	}

	public void setFileName(String fileName) {
		this.set("fileName", fileName);
	}

	public String getFilePath() {
		return this.get("filePath");
	}

	public void setFilePath(String filePath) {
		this.set("filePath", filePath);
	}

	public long getFileSize() {
		return this.get("fileSize");
	}

	public void setFileSize(long fileSize) {
		this.set("fileSize", fileSize);
	}

	public Date getCreatedDate() {
		return this.get("createdDate");
	}

	public void setCreatedDate(Date createdDate) {
		this.set("createdDate", createdDate);
	}

	public List<EmailAttachment> findByEmailId(long emailId) {
		List<EmailAttachment> result = new ArrayList<EmailAttachment>();
		StringBuilder sBuilder = new StringBuilder(
				"SELECT * FROM EmailAttachment WHERE ");
		sBuilder.append("emailId = ?");

		result = EmailAttachment.dao.find(sBuilder.toString(), emailId);

		return result;
	}

	public int countByEmailId(long emailId) {
		int result = 0;
		StringBuilder sBuilder = new StringBuilder(
				"SELECT COUNT(*) FROM EmailAttachment WHERE ");
		sBuilder.append("emailId = ?");
		result = Db.queryLong(sBuilder.toString(), emailId).intValue();

		return result;
	}
}